using System.ComponentModel;
using eProject.View.Properties;

namespace eProject.View
{
    public class ApplicationSettings : INotifyPropertyChanged
    {

        private bool _isDetailMode;
        public bool IsDetailMode
        {
            get { return _isDetailMode; }
            set
            {
                if (_isDetailMode == value) return;
                _isDetailMode = value;
                InvokePropertyChanged("IsDetailMode");
            }
        }

        private string _culture;
        public string Culture
        {
            get { return _culture; }
            set
            {
                if (value == null) return;
                if (_culture == value) return;
                _culture = value;
                InvokePropertyChanged("Culture");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void InvokePropertyChanged(string prop)
        {
            PropertyChangedEventHandler changed = PropertyChanged;
            if (changed != null) changed(this, new PropertyChangedEventArgs(prop));
        }

        public void Save()
        {
            Settings.Default.UICulture = Culture;
            Settings.Default.IsDetailMode = IsDetailMode;
        }

        public void Load()
        {
            Culture = Settings.Default.UICulture;
            IsDetailMode = Settings.Default.IsDetailMode;
        }
    }
}